package mybatis.base;

import cur.nature.tinyorm.core.annotation.Column;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author wujian
 * @date 2018年6月24日 下午5:35:14
 */
@Data
public class BasePO extends cur.nature.framework.mvc.base.BasePO implements Serializable {
    @Column(name = "id", isPK = true, desc = "主键")
    private Long id;
    /**
     *创建用户
     */
    @Column(name = "create_user", desc = "创建用户")
    private Long createUser;

    /**
     * 创建日期
     */
    @Column(name = "create_date", desc = "创建日期")
    private Date createDate;

    /**
     *修改用户
     */
    @Column(name = "modify_user", desc = "修改用户")
    private Long modifyUser;

    /**
     * 修改日期
     */
    @Column(name = "modify_date", desc = "修改日期")
    private Date modifyDate;

    /**
     * 是否已删除(1:是，0否)
     */
    @Column(name = "is_delete", desc = "是否已删除")
    private Integer isDelete;

    public BasePO() {
//        setBase(0);
    }

    public void setCreateBase(){
        setBase(0L, 1);
    }

    public void setModifyBase(){
        setBase(0L, 2);
    }
    public void setDeleteBase(){
        setBase(0L, 3);
    }

    public void setBase(Long userId, Integer operateType){
        this.modifyUser = userId;
        this.modifyDate = new Date();
        this.isDelete = 0;
        if(null==id || (operateType != null && operateType == 1)){
            this.createUser = userId;
            this.createDate = new Date();
        }
    }
}

